import axios from "axios";
import { Toast } from "vant";
let loadingToast = null;
axios.defaults.baseURL = "http://localhost:3000";
axios.interceptors.request.use((config)=>{
  loadingToast = Toast.loading({
    duration:0,
    forbidClick:true,
    overlay:true,
    message:"加载中"
  })
  return config
})
axios.interceptors.response.use((res)=>{
  if(res.status != 200){
    Toast.fail("请求异常");
    return Promise.reject(res);
  }
  if(res.status == 200){
    loadingToast.clear();
  }
  return res.data;
})

export default axios